<template>
  <div class="fault">
    <div class="center">
      <div class="center-item">
        <div class="title">今日故障</div>
        <div>
          <span class="value">{{fault?.day || ''}}</span>
          <span class="cam">次</span>
        </div>
      </div>
      <div class="center-item">
        <div class="title">累计故障</div>
        <div>
          <span class="value">{{fault?.days || ''}}</span>
          <span class="cam">次</span>
        </div>
      </div>
    </div>
    <MouldBoxVue
      style="margin-bottom:.9375rem;"
      height="9.25rem"
      :datas="lineLists"
      :chartOption="{
        color:['#EF303B'],
        area:true,
        unit:'次'
      }"
      :text="['泵房故障']"
      :chartTitle="chartTitle + '泵房故障监测趋势'">
    </MouldBoxVue>
    <MouldBoxVueV2
      height="9rem"
      :datas="pieLists"
      :color="['#34C8FF','#01FDFF','#57FFAA','#FFD100','#FB9B2A']"
      :orderKeys="orderKeys"
      text="泵组故障次数"
      :src="require('@/assets/img/water/error.png')"
      :chartTitle="chartTitle + '泵房故障告警分类'">
    </MouldBoxVueV2>
  </div>
</template>

<script>
import MouldBoxVue from '../common/MouldBox.vue';
import MouldBoxVueV2 from '../common/MouldBoxV2.vue';
export default {
  data() {
    return {
    };
  },
  props: {
    chartTitle: {
      typeof: String,
      default: ''
    },
    fault: {
      typeof: Object,
      default: () => {}
    },
    src: {
      typeof: String,
      default: ''
    }
  },

  components: {
    MouldBoxVue,
    MouldBoxVueV2
  },

  computed: {
    lineLists() {
      return this.fault?.line || [];
    },
    pieLists() {
      return this.fault?.pie || [];
    },
    orderKeys() {
      let data = [];
      if (this.pieLists && this.pieLists.length > 0) {
        data = this.pieLists.map(item => item.level1Desc);
      }
      return data;
    }
  },

  methods: {}
};
</script>
<style scoped lang="scss">
.fault {
  .center {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: .9375rem;
    .center-item {
      width: 10rem;
      height: 2.75rem;
      border-radius: 0.25rem;
      background-color: #273443;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0.625rem;
      box-sizing: border-box;
      .title {
        color: #d8d8d8;
        font-size: 0.875rem;
      }
      .value {
        font-size: 0.875rem;
        color: #EF303B;
        margin-right: 0.3125rem;
      }
      .cam {
        font-size: 0.75rem;
        color: #8d8d8d;
      }
    }
  }
}
</style>
